package indi.jp.project.business.yunying.controller;

import indi.jp.project.core.entity.JsonResult;
import indi.jp.project.core.util.SimpleEntityUtil;
import indi.jp.project.business.yunying.entity.ProjectFiled;
import indi.jp.project.business.yunying.service.ProjectFiledService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

@RestController
@RequestMapping("/yunying/project")
public class ProjectFiledController {

    @Resource
    private ProjectFiledService projectFiledService;

    @GetMapping("/queryGrid")
    public JsonResult queryGrid(ProjectFiled projectFiled, HttpServletRequest request) throws Exception {
        SimpleEntityUtil<ProjectFiled> entityUtil = new SimpleEntityUtil<>();
        entityUtil.setBaseEntity(projectFiled, request);
        return projectFiledService.queryGrid(projectFiled);
    }

    @PostMapping("/save")
    public JsonResult save(@RequestBody @Valid ProjectFiled projectFiled, HttpServletRequest request) throws Exception {
        SimpleEntityUtil<ProjectFiled> entityUtil = new SimpleEntityUtil<>();
        entityUtil.setBaseEntity(projectFiled, request);
        return projectFiledService.save(projectFiled);
    }

    @GetMapping("/findById")
    public JsonResult findById(@RequestParam String id) throws Exception {
        return projectFiledService.findById(id);
    }

    @PostMapping("/deleteById")
    public JsonResult deleteById(@RequestParam String id) throws Exception {
        return projectFiledService.deleteById(id);
    }


}
